@echo on

rem fetch configuration values
call "%~sdp0..\..\Configuration\Configuration.bat"

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%APISOLUTIONFILE%" "Format Version 11.00" "Format Version 10.00"
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%APISOLUTIONFILE%" "Visual Studio 2010" "Visual Studio 2008"
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%APIPROJECTFILE%" "ToolsVersion=!d!4.0!d!" ToolsVersion=!d!3.5!d!
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%APIPROJECTFILE%" "<OldToolsVersion>3.5</OldToolsVersion>" "<OldToolsVersion>2.0</OldToolsVersion>"
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%PARSERENGINEPROJECTFILE%" "ToolsVersion=!d!4.0!d!" ToolsVersion=!d!3.5!d!
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%PARSERENGINEPROJECTFILE%" "<OldToolsVersion>3.5</OldToolsVersion>" "<OldToolsVersion>2.0</OldToolsVersion>"
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%PARSERENGINECOMPONENTTESTPROJECTFILE%" "ToolsVersion=!d!4.0!d!" ToolsVersion=!d!3.5!d!
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%PARSERENGINECOMPONENTTESTPROJECTFILE%" "<OldToolsVersion>3.5</OldToolsVersion>" "<OldToolsVersion>2.0</OldToolsVersion>"
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%RENDERENGINEPROJECTFILE%" "ToolsVersion=!d!4.0!d!" ToolsVersion=!d!3.5!d!
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%RENDERENGINEPROJECTFILE%" "<OldToolsVersion>3.5</OldToolsVersion>" "<OldToolsVersion>2.0</OldToolsVersion>"
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%RENDERENGINECOMPONENTTESTPROJECTFILE%" "ToolsVersion=!d!4.0!d!" ToolsVersion=!d!3.5!d!
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%RENDERENGINECOMPONENTTESTPROJECTFILE%" "<OldToolsVersion>3.5</OldToolsVersion>" "<OldToolsVersion>2.0</OldToolsVersion>"
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%LOADERENGINEPROJECTFILE%" "ToolsVersion=!d!4.0!d!" ToolsVersion=!d!3.5!d!
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%LOADERENGINEPROJECTFILE%" "<OldToolsVersion>3.5</OldToolsVersion>" "<OldToolsVersion>2.0</OldToolsVersion>"
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%LOADERENGINECOMPONENTTESTPROJECTFILE%" "ToolsVersion=!d!4.0!d!" ToolsVersion=!d!3.5!d!
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%LOADERENGINECOMPONENTTESTPROJECTFILE%" "<OldToolsVersion>3.5</OldToolsVersion>" "<OldToolsVersion>2.0</OldToolsVersion>"
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%DATAENGINEPROJECTFILE%" "ToolsVersion=!d!4.0!d!" ToolsVersion=!d!3.5!d!
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%DATAENGINEPROJECTFILE%" "<OldToolsVersion>3.5</OldToolsVersion>" "<OldToolsVersion>2.0</OldToolsVersion>"
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%DATAENGINECOMPONENTTESTPROJECTFILE%" "ToolsVersion=!d!4.0!d!" ToolsVersion=!d!3.5!d!
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%DATAENGINECOMPONENTTESTPROJECTFILE%" "<OldToolsVersion>3.5</OldToolsVersion>" "<OldToolsVersion>2.0</OldToolsVersion>"
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%CONTENTRENDERINGAPISYSTEMTESTPROJECTFILE%" "ToolsVersion=!d!4.0!d!" ToolsVersion=!d!3.5!d!
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%CONTENTRENDERINGAPISYSTEMTESTPROJECTFILE%" "<OldToolsVersion>3.5</OldToolsVersion>" "<OldToolsVersion>2.0</OldToolsVersion>"
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%CONTENTRENDERINGAPIPERFORMANCETESTPROJECTFILE%" "ToolsVersion=!d!4.0!d!" ToolsVersion=!d!3.5!d!
if %ERRORLEVEL% NEQ 0 goto END

rem replace content
%WINDIR%\system32\cscript.exe //B "%WSCRIPTREPLACEFILE%" "%CONTENTRENDERINGAPIPERFORMANCETESTPROJECTFILE%" "<OldToolsVersion>3.5</OldToolsVersion>" "<OldToolsVersion>2.0</OldToolsVersion>"
if %ERRORLEVEL% NEQ 0 goto END

rem jump over the error code
goto END

:ERROREND

rem the error level needs to be set
set ERRORLEVEL=1

:END

rem record the exit code
set EXITCODE=%ERRORLEVEL%

rem should the script pause or continue
if "%1"=="BATCH" exit %EXITCODE%

rem wait for a response then exit
pause